﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPGKata
{
    class Game
    {
        private Party party1;
        private Party party2;
        private int turn = 0;

        public Game()
        {
            party1 = new Party();
            party2 = new Party();
        }

        public void startGame()
        {
            initializeGame();
            Console.WriteLine("Let's start the game");
            while(!Lost())
            {
                startSimulation();
            }
            Console.WriteLine("End of the game");
            Console.ReadLine();
        }

        private bool Lost()
        {
            if (party1.Lost())
            {
                return true;
            }

            if (party2.Lost())
            {
                return true;
            }

            return false;
        }

        private void initializeGame()
        {
            party1.createParty();
            party2.createParty();
        }

        private void startSimulation()
        {
            Console.WriteLine(turn);
            switch (turn)
            {
                case 0:
                    party1.turn(party2);
                    turn = 1;
                    break;
                case 1:
                    party2.turn(party1);
                    turn = 0;
                    break;
            }
        }
    }
}
